package com.deepseek.project.data;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepseek.project.mapper.TalkInfoMessageMapper;
import com.deepseek.project.model.TalkInfoMessage;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 对话框对话记录信息基础服务层
 */
@Service
public class TalkInfoMessageData extends ServiceImpl<TalkInfoMessageMapper, TalkInfoMessage> {

    /**
     * 根据对话id获取对话信息列表
     */
    public List<TalkInfoMessage> getMessageListByTalkInfoId(Integer talkInfoId) {
        LambdaQueryWrapper<TalkInfoMessage> lambda = new LambdaQueryWrapper<>();
        lambda.eq(TalkInfoMessage::getTalkInfoId, talkInfoId);
        return baseMapper.selectList(lambda);
    }

    /**
     * 根据对话id删除对话信息
     */
    public void deleteByTalkInfoId(Integer talkInfoId){
        LambdaQueryWrapper<TalkInfoMessage> lambda = new LambdaQueryWrapper<>();
        lambda.eq(TalkInfoMessage::getTalkInfoId, talkInfoId);
        baseMapper.delete(lambda);
    }
}
